#define NO_FLOAT

#include <a_samp>
#include <a_players>

#include <string>

//#include <myfuncsdll>
#tryinclude num_players
//#include <fakecmd>


#define CLANTAG_START '['
#define CLANTAG_END ']'

#define ADMINS 4
new static const
adminplayers[ADMINS][] =
{
"ftk",
"dreft",
"Desfiter",
"DJ_Sateyv"
};

//new bool:adminsonline[NUM_PLAYERS];

//new bool:everyadmin;

forward IsItAdminPlayer(playerid);

public OnFilterScriptInit()
{
	//everyadmin = false;
	for(new i=0;i<NUM_PLAYERS;i++) if(IsPlayerConnected(i)) OnPlayerConnect(i);
	return true;
}

public OnFilterScriptExit()
{
	return true;
}

public OnPlayerConnect(playerid)
{
	//adminsonline[playerid] = (IsItAdminPlayer(playerid)!=-1)?true:false;
	SetPVarInt(playerid, "isadmin", IsItAdminPlayer(playerid)!=-1);
	return true;
}

public OnPlayerDisconnect(playerid)
{
	SetPVarInt(playerid, "isadmin", false);
	return true;
}

public OnPlayerCommandText(playerid,cmdtext[])
{
	#define STARTCMP(%1,%2,%3) (!strcmp(%1, %2, true, %3))
	if(STARTCMP(cmdtext, "/tempadmin", 10))
	{
		cmdtext[0] = cmdtext[12] - '0';
		if(cmdtext[0] < 0 || !IsPlayerConnected(cmdtext[0])) 
			return false;
		SetPVarInt(cmdtext[0], "isadmin", true);
		return true;
	}
	if(STARTCMP(cmdtext, "/deadmin", 8))
	{
		cmdtext[0] = cmdtext[10] - '0';
		if(cmdtext[0] < 0 || !IsPlayerConnected(cmdtext[0])) 
			return false;
		SetPVarInt(cmdtext[0], "isadmin", false);
		return true;
	}
	return false;
}

public IsItAdminPlayer(playerid)
{
	new PlayerName[MAX_PLAYER_NAME];
	//new sfound;
	//if(everyadmin) return(200+playerid);
	GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	for(new i=0;i<ADMINS;i++)
		if(strcmp(PlayerName,adminplayers[i], false) == 0) return i;
		//else if(sfound > 0 && PlayerName[0] == CLANTAG_START && PlayerName[sfound-1] == CLANTAG_END) return i;
	return -1;
}

